import java.awt.Image;
import java.awt.Graphics;
import java.awt.Rectangle;

/**
 * Actor class, originally based on the  class from http://www.brackeen.com/javagamebook/
 * 
 * Now implements a common interface for objects that can appear on a game canvas.
 * These objects need to be able to update based on the time elapsed and be able
 * to draw themselves given the proper graphics object.
 * 
 * @author ggere
 *
 */

public class Actor {

    protected Animation anim;

    protected int x;
    protected int y;
    protected int height;
    protected int width;
    
    // flag to tell game loop that this actor can be destroyed.
    protected boolean markedForDeath;
    

    /**
     * Creates a new Actor object with the specified Animation.
     * @param anim
     */
    public Actor(Animation anim) {
        this.anim = anim;
    }
    
    /**
     * Updates the current actor's anim based on the elapsedtime.
     * @param elapsedTime in nanos
     */
    public void update(double elapsedTime) {
        anim.update(elapsedTime);
    }

    /**
     * Gets this Actor's width, based on the size of the current image.
     * @return the width in pixels
     */
    public int getWidth() {
        return anim.getImage().getWidth(null);
    }

    /**
     * Gets this Actor's height, based on the size of the current image.
     * @return the height in pixels.
     */
    public int getHeight() {
        return anim.getImage().getHeight(null);
    } 

    /**
        Gets this Actor's current image.
    */
    public Image getImage() {
        return anim.getImage();
    }
    
    public void draw(Graphics g) {
    	g.drawImage(getImage(), x, y, null);
    }
    
	public Rectangle getBounds() {
		return new Rectangle(x,y,width,height);
	}
	
	public void collision(Actor a){
		
	}    
}
